<template>
  <div class="layui-row">
      <!-- 头部导航块 -->
      <top-lump>
        <div class="layui-btn-group">
            <router-link to="/addInterface"> <button class="layui-btn">新增接口</button> </router-link>
            <span class="layui-breadcrumb kgo-top-lump-breadcrumb" lay-separator="#">
                <a># 编程规范查询</a>
            </span>
        </div>
      </top-lump>
      <info-lump>
        <base-card title="编程规范查询" minHeight="700px">
             <table class="layui-table" lay-skin="nob" lay-size="lg">
                <colgroup>
                    <col>
                    <col>
                    <col>
                    <col>
                    <col>
                </colgroup>
                 <thead>
                    <tr>
                        <th>接口名称</th>
                        <th>版本号</th>
                        <th>地址</th>
                        <th>备注</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="item in interfaceList" :code="item.id">
                        <td v-on:click="displayInterface(item.id)">{{item.name}}</td>
                        <td v-on:click="displayInterface(item.id)">{{item.version}}</td>
                        <td v-on:click="displayInterface(item.id)">{{item.url}}</td>
                        <td v-on:click="displayInterface(item.id)">{{item.remark}}</td>
                        <td style="text-align: center;">
                          <div class="layui-btn-group">
                            <button class="layui-btn layui-btn-sm" v-on:click="displayInterface(item.id)">
                              <i class="layui-icon">&#xe60b;</i>
                            </button>
                            <button class="layui-btn layui-btn-sm" v-on:click="editInterface(item.id)">
                              <i class="layui-icon">&#xe642;</i>
                            </button>
                            <button class="layui-btn layui-btn-sm" v-on:click="deleteThisInterface(item.id)">
                              <i class="layui-icon">&#xe640;</i>
                            </button>
                          </div>
                        </td>
                    </tr>
                </tbody>
            </table>

        </base-card>
      </info-lump>


  </div>
</template>

<script>

export default {
    data () {
        return {
            interfaceList:[],
        }
    },
    created(){
       this.initInterfaceInfo();
    },
    mounted(){

    },
    methods:{
      /**
       * 初始化标准信息
       */
        initInterfaceInfo:function(){
            var url = this.$store.state.RootURL + "/interfaces";
            var project_id = this.$store.state.projectId;
            var that = this;
            $.ajax({
                url: url,
                type:"get",
                async: false,
                dataType:'json',
                data:{'projectId':project_id},
                success: function(data){
                  that.interfaceList = data.data;
                }
            });
        },
        /**
         * 跳转到接口
         */
        displayInterface:function(id){

           this.$router.push({
                path:"/showInterface",
                name:'展现接口',
                params:{
                    id:id
                }

            });
        },
        /**
         * 删除规范信息
         */
        deleteThisInterface:function(id){
            layer.msg("为保证接口完整，该功能暂不开放！待权限功能开放完成，功能开放");
            return ;
            var deleteurl = this.$store.state.RootURL+"/detele/standard";
            var that = this;
            layer.alert('确认删除该接口！', {
              skin: 'layui-layer-molv' //样式类名
              ,closeBtn: 0}, function(){
                $.ajax({
                  url: deleteurl,
                  type:"GET",
                  async: true,
                  dataType:'json',
                  data: {"id":id},
                  success: function(data){
                    layer.msg(data.msg);
                    that.initInterfaceInfo();
                  }
              });

            });


        },
        editInterface:function(id){
          console.log(id);
           this.$router.push({
                path:"/editInterface",
                name:'编辑接口',
                params:{
                    id:id
                }

            });
        }
    }
}
</script>

<style lang="scss">
.kgo-input-text{
    height: 35px;
    width: 100%;
    border-radius: 5px;
    border: 1px solid #e6e6e6;
}
</style>
